<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
<style type="text/css">
	ul{
		margin-left:25;padding:0;
 		list-style:none; 
	}
   .item{
        width: 90px;
	    display: inline-block;
	    margin-left: 5px;
    }
</style>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
	<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		<div id="splitter1" class="mini-splitter" vertical="true" style="width:100%;height: 70px;min-width: 800px">
		<div class="splitterDiv" style="border: none;">
			<table style="width:100%;">
				<tr>
					<td style="width:30%;">
		        		<span class="item">开始时间：</span>
		                <input id="create_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">截止时间：</span>
		                <input id="end_time" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">编号：</span>
		                <input id="serialNum" emptyText="请输入编号" class="mini-textbox" style="width:160px;" />
		        	</td>
		        	<td style="display: inline-block;"><a class="mini-button" iconCls="icon-search" onclick="search()">查询</a></td>
				</tr>
				<tr>
				    <td style="width:30%;">
		                <span class="item">更新开始时间：</span>
				    	<input id="u_stime" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		            </td>
					<td style="width:30%;">
		                <span class="item">更新截止时间：</span>
				    	<input id="u_etime" emptyText="请选择..." class="mini-datepicker" style="width:160px;" format="yyyy-MM-dd HH:mm:ss" timeFormat="HH:mm:ss" showTime="true" allowInput="false"/>
		            </td>
					<td style="width:30%;">
		        		<span class="item">话务类别：</span>
		        		<input id="s_category" showNullItem="true" nullItemText="全部" class="mini-combobox" style="width:160px;" textField="keyValue" valueField="keyName" emptyText="请选择..."
   				 		url="dictionary_cm_key_val_view.do?typeName=CALL_TASK_TYPE" allowInput="false"/>
		        	</td>
		        	<td style="display: inline-block;"><a href="javascript:showHq();">更多</a></td>
				</tr>
			</table>
		</div>
		<div visible="false" class="splitterDiv" style="border: none;">
			<table style="width:100%;">
				<tr>
					<td style="width:30%;">
		                <span class="item">中心：</span>
				    	<input id="cur_ser_center" emptyText="请选择..." showNullItem="true" nullItemText="全部" class="mini-combobox" style="width:160px;" textField="name" valueField="id" 
        				onvaluechanged="onCenterChanged" url="user_find_center.do" />
		            </td>
					<td style="width:30%;">
		                <span class="item">话务组：</span>
				    	<input id="cur_ser_group" emptyText="请先选择中心" class="mini-combobox" style="width:160px;" textField="name" valueField="id" 
       					onvaluechanged="onDeptChanged" />
		            </td>
					<td style="width:30%;">
		                <span class="item">创建者：</span>
				    	<input id="seat" emptyText="请先选择话务组" class="mini-combobox" style="width:160px;" textField="name" valueField="id"/>
		            </td>
		        </tr>
		        <tr>
		            <td style="width:30%;">
		        		<span class="item">相关手机号：</span>
		        		<input id="s_relatedPhone" emptyText="请输入手机号码" class="mini-textbox" style="width:160px;"/>
		        	</td>
					<td style="width:30%;">
		        		<span class="item">外线号码：</span>
		        		<input id="s_outsideNum" emptyText="请输入外线号码" class="mini-textbox" style="width:160px;"/>
		        	</td>
		            <td style="width:30%;"></td>
		            <td style="display: inline-block;"><a href="javascript:hideHq();">收起</a></td>
				</tr>
			</table>
		</div>
	</div>
	</div>
	<div id="toolbar1" class="mini-toolbar" style="padding:2px;">
	    <table style="width:100%;">
	        <tr>
		        <td style="width:100%;">
		        	<sec:authorize url='/call_manage_terminate_export_cur.do'>
		            <li class="mini-button" iconCls="icon-download" onclick="unaExportCurrent()">导出当前</li>
	   				<li class="mini-button" iconCls="icon-download" onclick="unaExportAll()">导出全部</li>
		            </sec:authorize>
		        </td>
	        </tr>
	    </table>
	</div>
	<div class="mini-fit" >
	<div id="datagrid1" class="mini-datagrid" onlyCheckSelection="true" multiSelect="true" idField="id" pageSize="20" url="call_manage_center_all_view.do" style="width:100%;height:100%;">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div type="checkcolumn" ></div>
			<div field="serialNum" width="100" headerAlign="center" align="center">编号</div>
			<sec:authorize url='/call_manage_my_unt_open.do'>
			<div field="pocessingStatus" width="80" headerAlign="center" renderer="onActionRenderer" align="center">相关操作</div>
			</sec:authorize>
			<div field="categoryValue" width="80" headerAlign="center" align="center">话务类别</div>
			<div field="totalNum" width="60" headerAlign="center" align="center">订单总数</div>
			<div field="singular" width="60" headerAlign="center" align="center">成单数</div>
			<div field="unpaired" width="60" headerAlign="center" align="center">未成单数</div>
			<div field="createTime" width="130" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">创建时间</div>
			<div field="updateTime" width="130" headerAlign="center" align="center" allowSort="true" dateFormat="yyyy-MM-dd HH:mm:ss">更新时间</div>
			<div field="createUserName" width="60" headerAlign="center" align="center">创建者</div>
			<div field="remark" width="100" headerAlign="center" align="center">备注</div>
			<div field="outsideNum" width="100" headerAlign="center" align="center">外线号码</div>
			<div field="relatedPhone" width="100" headerAlign="center" align="center">相关手机号</div>
		</div>
	</div>
	</div>
<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	grid.load();
	
	// 打开任务
	function onActionRenderer(e) {
		var record = e.record;
		return '<a href="javascript: openTask('+record._uid+');">打开任务</a>';
	}
	
	function openTask(row_uid) {
		var row = grid.getRowByUID(row_uid);
        mini.open({
            url: "call_manage_my_unt_open.do",
            title: "打开任务", width: 1000, height: 750,
            allowResize: false,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { row: row };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
            	
            }
        });
	}
	
	// 获取批量选择的数据
	function getSelectRows(){
		var rows = grid.getSelecteds();
		var id = [];
		if(rows.length > 0){
			var ids = [];
            for (var i = 0, l = rows.length; i < l; i++) {
                var r = rows[i];
                ids.push(r.id);
            }
            id = ids.join(',');
		}
		return id;
	}
	
	function search() {
		var c1 = mini.get("create_time").getFormValue();
		var c2 = mini.get("end_time").getFormValue();
		var serialNum = mini.get("serialNum").getFormValue();
		var category = mini.get("s_category").getFormValue();
		var relatedPhone = mini.get("s_relatedPhone").getFormValue();
		var outsideNum = mini.get("s_outsideNum").getFormValue();
		var createUser = mini.get("seat").getFormValue();
		var u1 = mini.get("u_stime").getFormValue();
		var u2 = mini.get("u_etime").getFormValue();
		grid.load({ ustime:u1,uetime:u2,stime:c1,etime:c2,serialNum:serialNum,category:category,relatedPhone:relatedPhone,outsideNum:outsideNum,createUser:createUser,listType: 1});
	}

	//批量导出当前页
	function unaExportCurrent(){
		var data = grid.data;
        var ids = [];
        $.each(data , function(){
            ids.push(this.id);
        });
        var id = ids.join(',');
        location.href="call_manage_center_exports_cur.do?id=" +id;
	}
	
	function showHq(){
		var splitter1 = mini.get("splitter1");
		$("#splitter1").css("height","140px");
		splitter1.showPane("2");
	}

	function hideHq(){
		var splitter1 = mini.get("splitter1");
		$("#splitter1").css("height","70px");
		splitter1.hidePane("2");
	}
	
	//批量导出全部
	function unaExportAll(){
		var c1 = mini.get("create_time").getFormValue();
		var c2 = mini.get("end_time").getFormValue();
		var serialNum = mini.get("serialNum").getFormValue();
		var category = mini.get("s_category").getFormValue();
		var relatedPhone = mini.get("s_relatedPhone").getFormValue();
		var outsideNum = mini.get("s_outsideNum").getFormValue();
		var createUser = mini.get("seat").getFormValue();
		var u1 = mini.get("u_stime").getFormValue();
		var u2 = mini.get("u_etime").getFormValue();
		location.href="call_manage_center_exports_all.do?stime="+c1+"&etime="+c2
			+"&serialNum="+serialNum+"&category="+category+"&relatedPhone="+relatedPhone
			+"&outsideNum="+outsideNum+"&createUser="+createUser+"&ustime"+u1+"&uetime"+u2;
	}
	
	function onDeptChanged(e) {
		var curSer = mini.get("seat");
		curSer.setValue("");
	    var url = "user_cur_ser.do?groupId=" + e.value;
	    curSer.setUrl(url);
	}

	function onCenterChanged(e){
		var curSer = mini.get("seat");
		curSer.setValue("");
		var url = "user_find_group.do?centerId=" + e.value;
		var curGroup = mini.get("cur_ser_group");
		curGroup.setValue("");
		curGroup.setUrl(url);
	}
</script>
</body>
</html>